<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
    <style>
        div{
            width: 600px;
            height: 1000px;
            margin: 100px auto;
        }
        *{
            margin: 0px;
            padding: 0px;
            list-style: none;
        }
        li{
            opacity: 0.5;
        }
        img{
            width: 200px;
            height: 200px;
            float: left;

        }
       .current{
            opacity: 1;
        }
        .a3{
            width: 50px;
            height: 50px;
            margin: 10px auto;
           
            
        }
    </style>
    <body>
        <div class="a1">
            <ul>
                <li class="current">
                    <img src="images/1.jpg" alt="">
                </li>
                <li>
                    <img src="images/2.jpg" alt="">
                </li>
                <li>
                    <img src="images/4.jpg" alt="">
                </li>
                <li>
                    <img src="images/3.jpg" alt="">
                </li>
                <li>
                    <img src="images/5.jpg" alt="">
                </li>
                <li>
                    <img src="images/6.jpg" alt="">
                </li>
            </ul>
            
            <button class="a3" id="but">开始抽奖</button>
            
        </div>
        
        <script>
            var i=0;
            var timer;
            var a=document.getElementsByTagName('li');
            var but=document.getElementById('but');
            but.onclick=function(){
                clearInterval(timer)
                var num=6+parseInt(Math.random()*14);
                timer=setInterval(function(){
                    num=num-1;
                    if(num<0){
                        clearInterval(timer);
                    }
                    i=i+1;
                    if(i>5){
                        i=0;
                        a[i].className='current' 
                    }
                    for(var j=0;j<a.length;j++){
                    a[j].className = '';
                }
                    a[i].className='current';
                },100)
            }
        </script>
    </body>
</html>